package com.blog.wu.myblog.entity;

import com.blog.wu.myblog.base.DataEntity;

import java.util.Objects;

/**
 * @Author wuyanshen
 * @Date 2018-11-02 11:24 AM
 * @Discription 描述
 */
public class Permission extends DataEntity<Permission> {

    private String permissionName;//权限名称

    private String url;//资源url

    private String name;//资源名称

    private String icon;//图标

    private String type;//资源类型 0：目录 1:菜单 2：按钮

    private String isHide;//是否隐藏

    private String sort;//排序

    private String level;//节点在树的第几层

    private String parentId;//父节点id

    private String nodeId;//当前节点id

    private String checked;//是否选中

    private String target;//跳转到的目标


    public Permission() {
    }

    public Permission(String permissionName, String url, String name, String icon, String type, String isHide, String sort, String level, String parentId, String nodeId, String checked, String target) {
        this.permissionName = permissionName;
        this.url = url;
        this.name = name;
        this.icon = icon;
        this.type = type;
        this.isHide = isHide;
        this.sort = sort;
        this.level = level;
        this.parentId = parentId;
        this.nodeId = nodeId;
        this.checked = checked;
        this.target = target;
    }

    public String getChecked() {
        return checked;
    }

    public void setChecked(String checked) {
        this.checked = checked ==null?null:checked.trim();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null?null:name.trim();
    }

    public String getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = level==null?null:level.trim();
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId==null?null:parentId.trim();
    }

    public String getNodeId() {
        return nodeId;
    }

    public void setNodeId(String nodeId) {
        this.nodeId = nodeId==null?null:nodeId.trim();
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url == null?null:url.trim();
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon ==null?null:icon.trim();
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type == null?null:type.trim();
    }

    public String getIsHide() {
        return isHide;
    }

    public void setIsHide(String isHide) {
        this.isHide = isHide == null?null:isHide.trim();
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort == null?null:sort.trim();
    }

    public String getPermissionName() {
        return permissionName;
    }

    public void setPermissionName(String permissionName) {
        this.permissionName = permissionName == null?null:permissionName.trim();
    }

    public String getTarget() {
        return target;
    }

    public void setTarget(String target) {
        this.target = target;
    }

    public boolean isRootNode() {
        return parentId.equals("0");
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Permission that = (Permission) o;
        return Objects.equals(permissionName, that.permissionName) &&
                Objects.equals(url, that.url) &&
                Objects.equals(name, that.name) &&
                Objects.equals(icon, that.icon) &&
                Objects.equals(type, that.type) &&
                Objects.equals(isHide, that.isHide) &&
                Objects.equals(sort, that.sort) &&
                Objects.equals(level, that.level) &&
                Objects.equals(parentId, that.parentId) &&
                Objects.equals(nodeId, that.nodeId) &&
                Objects.equals(target, that.target) &&
                Objects.equals(checked, that.checked);
    }

    @Override
    public int hashCode() {
        return Objects.hash(permissionName, url, name, icon, type, isHide, sort, level, parentId, nodeId, target, checked);
    }
}
